<div class="guide_service_dialog" id="single" <if condition="$increment eq 1">style="display:none;"</if>>
    <!--使用套餐内条数-->
    <if condition="$mode eq 'setmeal'">
        <div class="guide_jobs_about">
            <eq name="jobs_num" value="1">
            <div class="guide_service_dialog_head">
                <div class="head_tab select" data="single">普通刷新<div class="bottom_line"></div></div>
                <div class="head_tab" data="increment">智能刷新<div class="bottom_line"></div><div class="preferential icon2"></div></div>
                <div class="clear"></div>         
            </div>
            <div class="solid_line"></div>
            </eq>
            <div class="refresh_line">您今天还可免费刷新 <span class="yellow_light">{$free_time}</span> 次，本次刷新免费，是否立即刷新？</div>
            <eq name="jobs_num" value="1">
            <div class="tips_line link_blue">智能刷新无须值守，自动刷新提高职位曝光率。立即使用 <a class="change_tab" href="javascript:;" data="increment">智能刷新</a></div>
            </eq>
        </div>
    <!--使用积分全额兑换-->
    <elseif condition="$mode eq 'points'"/>
        <div class="guide_jobs_about">
            <eq name="jobs_num" value="1">
            <div class="guide_service_dialog_head">
                <div class="head_tab select" data="single">普通刷新<div class="bottom_line"></div></div>
                <div class="head_tab" data="increment">智能刷新<div class="bottom_line"></div><div class="preferential icon2"></div></div>
                <div class="clear"></div>         
            </div>
            <div class="solid_line"></div>
            </eq>
            <div class="tips_line_normal">本次刷新需要扣除 <span class="yellow_light">{$refresh_points}</span> {:C('qscms_points_byname')}，是否确定刷新？</div>
            <div class="tips_line link_blue mt_10">（原因：您今天的免费刷新次数已用完）</div>
            <div class="guide_btn_group txt_center">
                <div class="btn_guide" id="confirm_points_submit">确定刷新</div>
                <span class="ft_12">（您当前拥有 <span class="yellow_light">{$mypoints}</span> {:C('qscms_points_byname')}）</span>
            </div>
            <eq name="jobs_num" value="1">
            <div class="tips_line link_blue">智能刷新无须值守，自动刷新提高职位曝光率。立即使用 <a class="change_tab" href="javascript:;" data="increment">智能刷新</a></div>
            </eq>
        </div>
    <!--混合模式-->
    <else />
        <div class="guide_resume_down">
            <eq name="jobs_num" value="1">
                <div class="guide_service_dialog_head">
                    <div class="head_tab select" data="single">普通刷新<div class="bottom_line"></div></div>
                    <div class="head_tab" data="increment">智能刷新<div class="bottom_line"></div><div class="preferential icon2"></div></div>
                    <div class="clear"></div>         
                </div>
                <div class="solid_line"></div>
            </eq>
            <div class="tips_line_normal">本次刷新需要扣除 <span class="yellow_light">{:C('qscms_refresh_jobs_price')}</span> 元，是否确定刷新？</div>
            <div class="tips_line link_blue mt_10">（原因：您今天的免费刷新次数已用完）</div>
            <eq name="open_points_convert" value="1">
                <div class="guide_list_group last">
                    <div class="guide_list_left for_input">使用{:C('qscms_points_byname')}：</div>
                    <div class="guide_list_right">
                        <input class="input_coin" type="text" id="J_integralforcash_input" placeholder="请输入要抵扣的{:C('qscms_points_byname')}数" onkeyup="if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,'');" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))">&nbsp;&nbsp;&nbsp;&nbsp;您当前拥有 <span class="yellow_light">{$mypoints}</span> {:C('qscms_points_byname')}
                    </div>
                    <div class="clear"></div>
                </div>
                <div class="guide_list_group last">
                    <div class="guide_list_left">应付金额：</div>
                    <div class="guide_list_right">
                        <span class="yellow_light" id="pay_cash">{$need_cash}</span> 元&nbsp;&nbsp;&nbsp;&nbsp;{:C('qscms_points_byname')}已抵扣 <span class="yellow_light" id="J_integralforcashvalue">0</span> 元
                    </div>
                    <div class="clear"></div>
                </div>
            </eq>
            <div class="cash_btn_group">
                <div class="cash_btn_cell">
                    <a href="javascript:;" class="cash_pay_submit" payment="wxpay" form_id="cash_pay_form" data-action="{:U('CompanyService/jobs_refresh')}">
                        <div class="cell_icon"></div>
                        <div class="cell_txt">微信扫码支付</div>
                    </a>
                </div>
                <div class="cash_btn_cell">
                    <a href="javascript:;" class="cash_pay_submit" payment="alipay" form_id="cash_pay_form" data-action="{:U('CompanyService/jobs_refresh')}">
                        <div class="cell_icon icon2"></div>
                        <div class="cell_txt">支付宝快捷支付</div>
                    </a>
                </div>
                <div class="clear"></div>
            </div>
            <eq name="jobs_num" value="1">
                <div class="tips_line link_blue">预约刷新购买更优惠。VIP会员每天低至 <span class="yellow_light">{$max_discount}</span>  折，立即 <a class="change_tab" href="javascript:;" data="increment">预约刷新</a></div>
            </eq>
        </div>
    </if>
    <form target="_blank" id="cash_pay_form" method="post" action="{:U('jobs_refresh')}">
    <input type="hidden" name="yid" id="jobs_id" value="{$jobs_id}">
    <!--是否抵扣-->
    <input type="hidden" name="is_deductible" id="is_deductible" value="0">
    <!-- 抵现积分数-->
    <input type="hidden" name="deductible" id="deductible" value="">
    <input type="hidden" name="payment_name" id="payment_name" value="wxpay">
    </form>
</div>

<div class="guide_service_dialog" id="increment" <if condition="$increment neq 1">style="display:none;"</if>>
    <div class="guide_resume_down zn">
        <div class="guide_service_dialog_head">
            <div class="head_tab" data="single">普通刷新<div class="bottom_line"></div></div>
            <div class="head_tab select" data="increment">智能刷新<div class="bottom_line"></div><div class="preferential icon2"></div></div>
            <div class="clear"></div>         
        </div>
        <div class="solid_line"></div>
        <if condition="$is_free eq '1'">
        <div class="guide_package_list_group">
            <div class="package_list_head">
                <div class="list_head_left">套餐资源</div>
                <div class="list_head_center">普通会员价</div>
                <div class="list_head_right">VIP会员价</div>
                <div class="clear"></div>
            </div>
            <volist name="increment_arr" id="vo">
            <div class="package_list_cell">
                <div class="list_cell_left"><label><input class="J_radioitme_order" type="radio" name="list_cell" <if condition="$key eq '0'">checked</if>  my_price="{$vo['my_price']}" need_points="{$vo['need_points']}" project_id="{$vo['id']}">{$vo['name']}</label></div>
                <div class="list_cell_center"><span class="yellow_light">{$vo['my_price']}</span> 元 <span class="ft_12">({$vo['my_unit_price']/4} 元/{$unit_arr[$vo['cat']]})</span></div>
                <div class="list_cell_right"><span class="yellow_light">{$vo['vip_price']}</span> 元 <span class="ft_12">({$vo['vip_unit_price']/4} 元/{$unit_arr[$vo['cat']]})</span></div>
                <div class="clear"></div>
            </div>
            </volist>
        </div>
        <else />
        <div class="guide_package_list_group">
            <div class="package_list_head">
                <div class="list_head_left">套餐资源</div>
                <div class="list_head_center">会员专享价</div>
                <div class="list_head_right">折后优惠</div>
                <div class="clear"></div>
            </div>
            <volist name="increment_arr" id="vo">
            <div class="package_list_cell">
                <div class="list_cell_left"><label><input class="J_radioitme_order" type="radio" name="list_cell" <if condition="$key eq '0'">checked</if> my_price="{$vo['my_price']}" need_points="{$vo['need_points']}" project_id="{$vo['id']}">{$vo['name']}</label></div>
                <div class="list_cell_center"><span class="yellow_light">{$vo['my_price']}</span> 元 <span class="ft_12">({$vo['my_unit_price']/4} 元/{$unit_arr[$vo['cat']]})</span></div>
                <div class="list_cell_right">省 <span class="yellow_light">{$vo['my_saved_price']}</span> 元</div>
                <div class="clear"></div>
            </div>
            </volist>
        </div>
        </if>
        <div class="dashed_line"></div>
        <div class="points_pay_increment">
            <div class="guide_list_group last">
                <div class="guide_list_left">所需{:C('qscms_points_byname')}：</div>
                <div class="guide_list_right">
                    <span class="yellow_light need_points"></span>&nbsp;&nbsp;&nbsp;&nbsp;您当前拥有 <span class="yellow_light">{$mypoints}</span> {:C('qscms_points_byname')}
                </div>
                <div class="clear"></div>
            </div>
            <div class="guide_btn_group">
                <div class="btn_guide" id="points_convert">立即兑换</div>
            </div>
        </div>
        <div class="cash_pay_increment">
            <div class="guide_list_group last">
                <div class="guide_list_left for_input">使用{:C('qscms_points_byname')}：</div>
                <div class="guide_list_right">
                    <input class="input_coin" id="J_integralforcash_input_increment" type="text" placeholder="请输入要抵扣的{:C('qscms_points_byname')}数" onkeyup="if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,'');" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))">&nbsp;&nbsp;&nbsp;&nbsp;您当前拥有 <span class="yellow_light">{$mypoints}</span> {:C('qscms_points_byname')}
                </div>
                <div class="clear"></div>
            </div>
            <div class="guide_list_group last">
                <div class="guide_list_left">应付金额：</div>
                <div class="guide_list_right">
                    <span class="yellow_light" id="pay_cash_increment"></span> 元&nbsp;&nbsp;&nbsp;&nbsp;{:C('qscms_points_byname')}已抵扣 <span class="yellow_light" id="J_integralforcashvalue_increment">0</span> 元
                </div>
                <div class="clear"></div>
            </div>
            <div class="cash_btn_group">
                <div class="cash_btn_cell">
                    <a href="javascript:;" class="cash_pay_submit" payment="wxpay" form_id="cash_pay_form_increment"  data-action="{:U('CompanyService/increment_add_save')}">
                        <div class="cell_icon"></div>
                        <div class="cell_txt">微信扫码支付</div>
                    </a>
                </div>
                <div class="cash_btn_cell">
                    <a href="javascript:;" class="cash_pay_submit" payment="alipay" form_id="cash_pay_form_increment"  data-action="{:U('CompanyService/increment_add_save')}">
                        <div class="cell_icon icon2"></div>
                        <div class="cell_txt">支付宝快捷支付</div>
                    </a>
                </div>
                <div class="clear"></div>
            </div>
        </div>
        <div class="tips_line link_blue">注：智能刷新每 6 小时执行一次自动刷新。</div>
    </div>
    <form target="_blank" id="cash_pay_form_increment" method="post" action="{:U('increment_add_save')}">
    <input type="hidden" name="jobs_id" id="jobs_id_increment" value="{$jobs_id}">
    <input type="hidden" name="pay_type" value="cash">
    <!--增值服务类型唯一标识-->
    <input type="hidden" name="service_type" value="{$cat}">
    <!--需要支付的现金-->
    <input type="hidden" id="amount" name="amount" value="">
    <!--是否抵扣-->
    <input type="hidden" name="is_deductible" id="is_deductible_increment" value="0">
    <!-- 抵现积分数-->
    <input type="hidden" name="deductible" id="deductible_increment" value="">
    <input type="hidden" name="payment_name" id="payment_name_increment" value="wxpay">
    <input type="hidden" id="project_id" name="project_id" value="{$increment_arr[0]['id']}">
    <!--不抵扣的情况下需要支付的积分-->
    <input type="hidden" id="total_points" name="total_points" value="{$increment_arr[0]['need_points']}">
    <input type="hidden" id="need_cash" name="need_cash" value="">
    </form>
</div>
    <input type="hidden" id="buy" name="buy" value="{$auto_refresh_log}">

<script type="text/javascript">
    $('.head_tab').click(function(event) {
        var data = $(this).attr('data');
        if (data == "increment") {
            $('.modal_footer').hide();
        } else {
            <if condition="$mode eq 'setmeal'">
                $('.modal_footer').show();
            </if>
        }
        $(".guide_service_dialog").hide();
        $("#"+data).show();
    });
    $('.change_tab').click(function(event) {
        var data = $(this).attr('data');
        $(".guide_service_dialog").hide();
        $("#"+data).show();
    });
    $("#J_integralforcash_input").keyup(function(){
        var thisvalue = $(this).val();
        var mypoints = parseInt("{$mypoints}");
        var current_points = parseInt("{$refresh_points}");
        var minpointsValue = mypoints >= current_points ? current_points : mypoints;
        if (thisvalue > minpointsValue) {
            $(this).val(minpointsValue);
        }
        if(parseInt($(this).val())>0){
            $("#is_deductible").val(1);
        }else{
            $("#is_deductible").val(0);
        }
        $("#deductible").val($(this).val());
        $("#pay_cash").text((parseInt("{:C('qscms_refresh_jobs_price')}")-parseFloat($(this).val()/parseInt("{:C('qscms_payment_rate')}"))).toFixed(2));
        $('#J_integralforcashvalue').text(parseFloat($(this).val()/parseInt("{:C('qscms_payment_rate')}")).toFixed(2));
    });
    $(".cash_pay_submit").click(function(){
        if(parseInt($("#buy").val())!=0){
            disapperTooltip("remind","该职位已设置自动刷新，不能重复购买，请重新选择职位！");
            return false;
        }
        $("#payment_name").val($(this).attr('payment'));
        $("#payment_name_increment").val($(this).attr('payment'));
        var formid = $(this).attr('form_id');
        var action_url = $(this).attr('data-action');
        if($(this).attr('payment')=='wxpay'){
            var qsDialog = $("#"+formid).dialog({
                title: '微信支付',
                loading:true,
                footer:false
            });
            $.ajax({
                cache: true,
                type: "POST",
                url:action_url,
                data:$('#'+formid).serialize(),
                dataType:"json",
                success: function(result) {
                    if(result.status==1){
                        qsDialog.setContent("<img src='"+result.data+"' alt='扫描二维码' width='250' height='250' />");
                        window.setInterval(run, 5000);
                    }else{
                        qsDialog.setContent(result.msg);
                        return false;
                    }
                }
            });
        }else{
            $("#"+formid).submit();
        }
    });
    $("#confirm_points_submit").click(function(){
        /*if(parseInt($("#buy").val())!=0){
            disapperTooltip("remind","该职位已设置自动刷新，不能重复购买，请重新选择职位！");
            return false;
        }*/
        var url = "{:U('CompanyService/jobs_refresh')}";
        var jobs_id = "{$jobs_id}";
        $.post(url,{yid:jobs_id},function(result){
            if(result.status==1){
                disapperTooltip("success",result.msg);
                setTimeout(function () {
                    window.location.reload();
                }, 2000);
            }else{
                disapperTooltip("remind",result.msg);
                return false;
            }
        },'json');
    });
    select_pay_type();
    // 套餐列表点击
    var $radiobj = $('.J_radioitme_order');
    $radiobj.live('click', function(event) {
        $("#project_id").val($(this).attr("project_id"));
        $("#total_points").val($(this).attr("need_points"));
        select_pay_type();
    });
    function select_pay_type(){
        var mypoints = parseInt("{$mypoints}");
        var current_points = parseInt($("#total_points").val());
        if(mypoints<current_points){
            $(".points_pay_increment").hide();
            $(".cash_pay_increment").show();
            $('#J_integralforcash_input_increment').val(mypoints);
            $('#deductible_increment').val(mypoints);
        }else{
            $(".points_pay_increment").show();
            $(".cash_pay_increment").hide();
            $('#J_integralforcash_input_increment').val(current_points);
            $('#deductible_increment').val(current_points);
        }
        $(".need_points").html(current_points);
        if(parseInt($('#J_integralforcash_input_increment').val())>0){
            $("#is_deductible_increment").val(1);
        }else{
            $("#is_deductible_increment").val(0);
        }
        var need_cash = current_points/parseInt("{$payment_rate}");
        $("#need_cash").val(need_cash.toFixed(2));
        $("#amount").val(need_cash.toFixed(2));
        $('#J_integralforcashvalue_increment').text(($('#J_integralforcash_input_increment').val()/parseInt("{$payment_rate}")).toFixed(2));
        if (parseInt($('#J_integralforcashvalue_increment').html())>0) {
            $("#pay_cash_increment").text((need_cash-parseFloat($('#J_integralforcashvalue_increment').text()).toFixed(2)).toFixed(2));
            $('#amount').val((parseFloat($('#need_cash').val())-parseFloat($('#J_integralforcashvalue_increment').text())).toFixed(2));
        } else {
            $("#pay_cash_increment").html(need_cash.toFixed(2));
            $('#amount').val(need_cash.toFixed(2));
        }
    }
    $("#J_integralforcash_input_increment").keyup(function(){
        var thisvalue = $(this).val();
        var mypoints = parseInt("{$mypoints}");
        var current_points = parseInt($("#total_points").val());
        var minpointsValue = mypoints >= current_points ? current_points : mypoints;
        if (thisvalue > minpointsValue) {
            $(this).val(minpointsValue);
        }
        if(parseInt($(this).val())>0){
            $("#is_deductible_increment").val(1);
        }else{
            $("#is_deductible_increment").val(0);
        }
        var need_cash = current_points/parseInt("{$payment_rate}");
        $("#need_cash").val(need_cash.toFixed(2));
        $("#deductible_increment").val($(this).val());
        $("#pay_cash_increment").text((need_cash-$(this).val()/parseInt("{$payment_rate}")).toFixed(2));
        $('#J_integralforcashvalue_increment').text(($(this).val()/parseInt("{$payment_rate}")).toFixed(2));
        $('#amount').val((parseFloat($('#need_cash').val())-parseFloat($('#J_integralforcashvalue_increment').text())).toFixed(2));
    });
    function run(){
        $.getJSON("{:U('check_weixinpay_notify')}",function(result){
            if(result.status==1){
               location.href=result.data;
            }
        });
    }
    $("#points_convert").click(function(){
        if(parseInt($("#buy").val())!=0){
            disapperTooltip("remind","该职位已设置自动刷新，不能重复购买，请重新选择职位！");
            return false;
        }
        ajax_pay('{$cat}','points');
    });
    function ajax_pay(type,pay_type){
        var project_id = $("#project_id").val();
        var jobs_id = $("#jobs_id_increment").val();
        var payment_name = "points";
        $.post("{:U('CompanyService/increment_add_save')}",{pay_type:pay_type,service_type:type,project_id:project_id,payment_name:payment_name,jobs_id:jobs_id},function(result){
            if(result.status==1){
                disapperTooltip("success", "兑换成功！");
                setTimeout(function () {
                    window.location.reload();
                }, 2000);
            }else{
                disapperTooltip("remind", result.msg);
                return false;
            }
        },'json');
    }
</script>